package com.ets.Expense_DAO;

import java.util.Date;
import com.ets.common.DataDictionaryConstants;
import com.ets.common.DateUtils;
import com.ets.common.Displayable;
import com.ets.common.Validator;

/******************************************************************************* 
 The <big><b>Expense</b></big> class implements the <b>Displayable</b> &
 <b>Cloneable</b> interfaces to create a <b>Expense</b> object
 <br><br>
 @author D.Merkling - 1:33:38 PM - Aug 22, 2011
 <br><br>
 @version 1.2  
*******************************************************************************/ 
public class Expense implements Displayable, Cloneable, DataDictionaryConstants
  {
   // Class variables for the Expense object
   private int    Stck_No;
   private int    Seq;
   private Date   Dt;
   private String Typ;
   private String Vndr;
   private String Desc;
   private double Qty;
   private double Price;
   private double Tax;
	   
   /******************************************************************************* 
	This constructor creates a new <b>Expense</b> object with default values
   *******************************************************************************/ 
   public Expense ()
	 {
	  this.Stck_No = 0;
	  this.Seq     = 0;
	  this.Dt      = DateUtils.getToday();
	  this.Typ     = " ";
	  this.Vndr    = " ";
	  this.Desc    = " ";
	  this.Qty     = 0.000;
	  this.Price   = 0.000;
	  this.Tax     = 0.00;
	 }

   /******************************************************************************* 
	This constructor creates a new <b>Expense</b> object with attribute values as
	defined by the provided parameters
	<br><br>
	@param Stock number An <b><i>int</i></b> variable
	@param Sequence An <b><i>int</i></b> variable
	@param Date A <b><i>Date</i></b> variable
	@param Type A <b><i>String</i></b> variable
	@param Vendor code A <b><i>String</i></b> variable
	@param Description A <b><i>String</i></b> variable
	@param Quantity A <b><i>double</i></b> variable
	@param Unit price A <b><i>double</i></b> variable
	@param Tax amount A <b><i>double</i></b> variable
   *******************************************************************************/ 
   public Expense (int Stck_No, int Seq, Date Dt, String Typ, String Vndr, String Desc, double Qty, double Price, double Tax)
	 {
	  this.Stck_No = Stck_No;
	  this.Seq     = Seq;
	  this.Dt      = Dt;
	  this.Typ     = Typ;
	  this.Vndr    = Vndr;
	  this.Desc    = Desc;
	  this.Qty     = Qty;
	  this.Price   = Price;
	  this.Tax     = Tax;
	 }
   
   /******************************************************************************* 
	Clones the current <b>Expense</b> object to create a new one
	<br><br>
	@return Expense - An <b>Expense</b> object
	@throws CloneNotSupportedException 
   *******************************************************************************/ 
   public Object clone () throws CloneNotSupportedException
	 {
	  return super.clone();
	 }

   /******************************************************************************* 
	Sets the <b><i>int</i></b> <b>Stck_No</b> attribute for the current
	<b>Expense</b> object
	<br><br>
	The value must be ...
	<br><br>
	@param Stck_No An <b><i>int</i></b> variable
   *******************************************************************************/ 
   public void setStckNo (int stckNo)
	 {
	  this.Stck_No = stckNo;
	 }

   /******************************************************************************* 
	Retrieves the <b><i>int</i></b> <b>Stck_No</b> attribute from the current
	<b>Expense</b> object
	<br><br>
	@return Stck_No - An <b><i>int</i></b> variable
   *******************************************************************************/ 
   public int getStckNo ()
	 {
	  return Stck_No;
	 }

   /******************************************************************************* 
	Sets the <b><i>int</i></b> <b>Seq</b> attribute for the current
	<b>Expense</b> object
	<br><br>
	The value must be ...
	<br><br>
	@param Seq An <b><i>int</i></b> variable
   *******************************************************************************/ 
   public void setSeq (int seq)
	 {
	  this.Seq = seq;
	 }

   /******************************************************************************* 
	Retrieves the <b><i>int</i></b> <b>Seq</b> attribute from the current
	<b>Expense</b> object
	<br><br>
	@return Seq - An <b><i>int</i></b> variable
   *******************************************************************************/ 
   public int getSeq ()
	 {
	  return Seq;
	 }

   /******************************************************************************* 
	Sets the <b><i>Date</i></b> <b>Dt</b> attribute for the current
	<b>Expense</b> object
	<br><br>
	The value must be ...
	<br><br>
	@param Dt A <b><i>Date</i></b> variable
   *******************************************************************************/ 
   public void setDt (Date dt)
	 {
	  this.Dt = dt;
	 }

   /******************************************************************************* 
	Retrieves the <b><i>Date</i></b> <b>Dt</b> attribute from the current
	<b>Expense</b> object
	@return Dt - A <b><i>Date</i></b> variable
   *******************************************************************************/
   public Date getDt ()
	 {
	  return Dt;
	 }

   /*******************************************************************************
	Sets the <b><i>String</i></b> <b>Typ</b> attribute for the current
	<b>Expense</b> object
	<br><br>
	The value must be uppercase, trimmed, left-justified, & exist in the cd_val
	table in the ETS/ET segment
	<br><br>
	@param Typ A <b><i>String</i></b> variable
   *******************************************************************************/
   public boolean setTyp (String typ)
	 {
	  String tmpTyp   = typ.trim();
	         tmpTyp   = tmpTyp.toUpperCase();
	  boolean isValid = Validator.isCodeValid("ETS", "ET", tmpTyp);
	  return isValid;
	 }

   /*******************************************************************************
	Retrieves the <b><i>String</i></b> <b>Typ</b> attribute from the current
	<b>Expense</b> object
	@return Typ - A <b><i>String</i></b> variable
   *******************************************************************************/
   public String getTyp ()
	 {
	  return Typ;
	 }

   /*******************************************************************************
	Sets the <b><i>String</i></b> <b>Vndr</b> attribute for the current
	<b>Expense</b> object
	<br><br>
	The value must be uppercase, trimmed, left-justified, & exist in the vendor
	table
	<br><br>
	@param Vndr A <b><i>String</i></b> variable
   *******************************************************************************/
   public boolean setVndr (String vndr)
	 {
	  String  tmpVndr = vndr.trim();
	          tmpVndr = tmpVndr.toUpperCase();
      boolean isValid = Validator.isVendorValid(tmpVndr);
      if (isValid)
	    {
	     this.Vndr    = tmpVndr;
	     return true;
	    }
	  else
	    {
	     return false;
	    }
	 }

   /*******************************************************************************
	Retrieves the <b><i>String</i></b> <b>Vndr</b> attribute from the current
	<b>Expense</b> object
	@return Vndr - A <b><i>String</i></b> variable
   *******************************************************************************/
   public String getVndr ()
	 {
	  return Vndr;
	 }

   /*******************************************************************************
	Sets the <b><i>String</i></b> <b>Desc</b> attribute for the current
	<b>Expense</b> object
	<br><br>
	The value must be trimmed & left-justified
	<br><br>
	@param Desc A <b><i>String</i></b> variable
   *******************************************************************************/
   public void setDesc (String desc)
	 {
	  String tmpDesc = desc.trim();
      this.Desc      = tmpDesc;
	 }

   /*******************************************************************************
	Retrieves the <b><i>String</i></b> <b>Desc</b> attribute from the current
	<b>Expense</b> object
	@return Desc - A <b><i>String</i></b> variable
   *******************************************************************************/
   public String getDesc ()
	 {
	  return Desc;
	 }
   
   /*******************************************************************************
	Sets the <b><i>double</i></b> <b>quantity</b> attribute for the current
	<b>Expense</b> object
	<br><br>
	@param Qty A <b><i>double</i></b> variable
   *******************************************************************************/
   public void setQty (double qty)
	 {
	  this.Qty = qty;
	 }

   /*******************************************************************************
	Retrieves the <b><i>double</i></b> <b>quantity</b> attribute from the
	current <b>Expense</b> object
	<br><br>
	@return Qty - A <b><i>double</i></b> variable
   *******************************************************************************/
   public double getQty ()
	 {
	  return Qty;
	 }
   
   /*******************************************************************************
	Sets the <b><i>double</i></b> <b>unit price</b> attribute for the current
	<b>Expense</b> object
	<br><br>
	@param Price A <b><i>double</i></b> variable
   *******************************************************************************/
   public void setPrice (double prc)
	 {
	  this.Price = prc;
	 }

   /*******************************************************************************
	Retrieves the <b><i>double</i></b> <b>unit price</b> attribute from the
	current <b>Expense</b> object
	<br><br>
	@return Price - A <b><i>double</i></b> variable
   *******************************************************************************/
   public double getPrice ()
	 {
	  return Price;
	 }
   
   /*******************************************************************************
	Sets the <b><i>double</i></b> <b>tax amount</b> attribute for the current
	<b>Expense</b> object
	<br><br>
	@param Tax A <b><i>double</i></b> variable
   *******************************************************************************/
   public void setTax (double tax)
	 {
	  this.Tax = tax;
	 }

   /*******************************************************************************
	Retrieves the <b><i>double</i></b> <b>tax amount</b> attribute from the
	current <b>Expense</b> object
	<br><br>
	@return Tax - A <b><i>double</i></b> variable
   *******************************************************************************/
   public double getTax ()
	 {
	  return Tax;
	 }
   
   /*******************************************************************************
	Determines whether or not all of the attribute values of one <b>Expense</b>
	object are equal to all of the attribute values of a second <b>Expense</b>
	object
	<br><br>
	@param object A	<b>Expense</b> object
	@return true/false - A <b><i>boolean</i></b> variable
   *******************************************************************************/
   public boolean equals(Object object)
     {
      if (object instanceof Expense)
        {
         Expense expns2 = (Expense) object;
         if (Stck_No == expns2.getStckNo() &&
             Seq     == expns2.getSeq()    &&
             Dt      == expns2.getDt()     &&
             Typ.equals(expns2.getTyp())   &&
             Vndr.equals(expns2.getVndr()) &&
             Desc.equals(expns2.getDesc()) &&
             Qty     == expns2.getQty()    &&
             Price   == expns2.getPrice()  &&
             Tax     == expns2.getTax())
         return true;
        }
      return false;
     }
   
   /*******************************************************************************
	Retrieves a formatted list of the attribute values of the current
	<b>Expense</b> object
	<br><br>
	@return string - A <b><i>String</i></b> variable
   *******************************************************************************/
   public String toString()
	 {
	  return "Stock number: " + this.Stck_No + "\n" +
		     "Sequence    : " + this.Seq     + "\n" +
	         "Date        : " + this.Dt      + "\n" +
		     "Type code   : " + this.Typ     + "\n" +
		     "Vendor code : " + this.Vndr    + "\n" +
		     "Description : " + this.Desc    + "\n" +
		     "Quantity    : " + this.Qty     + "\n" +
		     "Unit price  : " + this.Price   + "\n" +
             "Tax amount  : " + this.Tax     + "\n";
	 }
   
   /*******************************************************************************
	Retrieves a formatted displayable list of the attribute values of the current
	<b>Address</b> object
	<br><br>
	@return string - A <b><i>String</i></b> variable
   *******************************************************************************/
   public String getDisplayText()
    {
	  return toString();
    }
  }